/* include/kernel/minixfs.h 
 * 
 * This file is part of xnix. 
 * 
 * XNIX is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * XNIX is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with XNIX. If not, see <https://www.gnu.org/licenses/>
 */ 




#ifndef __MINIXFS_H
#define __MINIXFS_H


#define MAGIC 	0x138f

#ifndef __ASSEMBLER__

#include <sys/types.h>

struct minixfs_sb {
	/* number of inodes, and blocks */
	__uint16_t ninodes;

	/* this isn't only data-blocks, all the disk */
	__uint16_t nzones;
	
	/* zones of bitmaps used (it will be aligned to 1 if we don't 
	 * need a full zone) */
	__uint16_t imap_nzones;
	__uint16_t zmap_nzones;

	/* first data-zone: always root */
	__uint16_t first_data_zone;

	__uint16_t log_zone_size;

	/* max file size this fs supports (not the biggest file size 
	 * in the fs) */
	__uint32_t max_file_size;

	__uint16_t magic;
} __attribute__ ((packed));


struct minixfs_inode {
	__uint16_t mode;
	__uint16_t uid;

	__uint32_t size;
	__uint32_t time;

	__uint8_t gid;
	__uint8_t nlinks;

	__uint16_t zones[9];
};


#endif

/* assembly codes, and we only need to define some macros */

/* offsets in the super-block */
#define SB_NINODES 	0
#define SB_NZONES 	2
#define SB_IMAP_ZONES 	4
#define SB_ZMAP_ZONES 	6

#define SB_FIRSTDZONE 	8
#define SB_LOGZONESZ 	10

#define SB_MAXFSIZE 	12
#define SB_MAGIC 	16


#define ROOTINO 	1


#define INO_MODE 	0
#define INO_UID 	2
#define INO_SIZE	4
#define INO_TIME 	8
#define INO_GID 	12
#define INO_NLINKS 	13
#define INO_ZONES 	14

#define ZONES_INDIR 	7
#define ZONES_DINDIR 	8


#endif

